﻿using System.Collections.Generic;
using System.Web.Mvc;
using Nop.Web.Framework.Mvc;
using FluentValidation;
using Nop.Services.Localization;
using FluentValidation.Attributes;
using Nop.Web.Framework;
using Nop.Web.Framework.Validators;

namespace Nop.Web.Models.WindAlert
{
    [Validator(typeof(MetarValidator))]
    public partial class MetarModel : BaseNopEntityModel
    {
        public MetarModel()
        {
            AvailableMetars = new List<SelectListItem>();
        }
        [NopResourceDisplayName("Windalert.Aviation.Airport")]
        public string Airport { get; set; }

        [NopResourceDisplayName("Windalert.Aviation.MetarTaf")]
        public string MetarTaf { get; set; }

        public string  MetarListId { get; set; }

        [NopResourceDisplayName("Windalert.Aviation.MetarList")]
        public IList<SelectListItem> AvailableMetars { get; set; }

        public string MetarTafResults { get; set; }

        public bool IsRegistered { get; set; }
    }

    public class MetarValidator : BaseNopValidator<MetarModel>
    {
        public MetarValidator(ILocalizationService localizationService)
        {
            RuleFor(x => x.Airport).NotEmpty().WithMessage(localizationService.GetResource("WindAlert.Metar.AirportRequired"));
        }
    }
}